<%@ page import="support.*, java.util.*, java.sql.*, javax.sql.*" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> 
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<jsp:include page="header.jsp" />

<%  
// Get incoming parameter from previous page
String degreeLocation = (String)request.getParameter("location");

Vector degrees = (Vector)session.getAttribute("degrees");
if (degrees != null) {
	HashMap currentDegree = (HashMap)degrees.get( degrees.size() - 1 );
	currentDegree.put("degreeLocation", degreeLocation);
}

// Get Vector of universities
support s = new support(); 		
String path2 = config.getServletContext().getRealPath("universities.txt");
Vector tuples = s.getUniversities(path2);

Vector tuple = (Vector)tuples.get(0);

for (int index = 0; index < tuples.size(); index++) {
	tuple = (Vector)tuples.get(index);
	
	//search for state
	if (degreeLocation.equals((String)tuple.get(0))) {
		//found state
		break; 
	}
}

Vector universities = (Vector)tuple.get(1);
%>

	<div id="content" class="expand">
		<h2>Graduate Application</h2>
			
		<p>Select the university you received your degree from</p>

			<div id="c1">	
				<%
				int totalSize = universities.size();
				int almostThird = totalSize / 3;
				
				for (int i = 0; i < almostThird; i++) {
				%>
				    <html:link action="students/degreeUniversity">
					<html:param name="university" value='<%=  (String)universities.get(i)  %>'/> <%= universities.get(i) %>
					</html:link> <br/>
				<%
				}
				%>
			</div>
			
			<div id="c2">
				<% 
				for (int i = almostThird; i < (almostThird) * 2; i++) {
				%>
				    <html:link action="students/degreeUniversity">
					<html:param name="university" value='<%=  (String)universities.get(i)  %>'/> <%= universities.get(i) %>
					</html:link> <br/>
				<%
				}
				%>
			</div>
			
			<div id="c3">
				<% 
				for (int i = (almostThird) * 2; i < universities.size(); i++) {
				%>
				    <html:link action="students/degreeUniversity">
					<html:param name="university" value='<%=  (String)universities.get(i)  %>'/> <%= universities.get(i) %>
					</html:link> <br/>
				<%
				}
				%>
			</div>
			
		</div>
		
</body>
</html>